package com.jinke.api.modules.third.carryship.model.response;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.jinke.api.common.api.CommonResult;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

@Data
public class GetPriceResponse {
    private Integer responseCode;
    private String msg;
    private ResponseDate2 responseDate;

    @Data
    public class ResponseDate2 {
        private ResponseDateData data;

    }
    @Data
    public class ResponseDateData {
        private List<ResponseCodeHelp> responseCodeHelpList;

        @Data
        public class ResponseCodeHelp {
            private String responseCode;
            private String msg;
            private  ResponseDate1 responseDate;
        }
    }

    @Data
    public class ResponseDate1 {
        private GoBack goBack;

    }
    @Data
    public class GoBack {
        @JsonProperty("channelsCode")
        private String channelsCode;
        @JsonProperty("estimatedFreight")
        private BigDecimal estimatedFreight;
        @JsonProperty("channelsExperience")
        private String channelsExperience;
        @JsonProperty("channelsNote")
        private String channelsNote;

    }
    public CommonResult toCommonResult() {
        // 判断是否成功
        CommonResult commonResult = CommonResult.success();
        if (!isSuccess()) {
            commonResult = CommonResult.failed(msg);
        }
        return commonResult;
    }

    public boolean isSuccess() {
        boolean result = true;
        // 判断是否成功
        if (responseCode != 200000306) {
            result = false;
        }
        return result;
    }

}
